
import java.util.List;
import org.springframework.stereotype.Repository;

/**
* @author :${author}
* @description: ${desc}数据库操作类
* @create date: ${createDate}
*/

@Repository
public class ${entityName}Dao{

    @Autowired
    ${entityName}Mapper ${entityNameLower}Mapper;

    /**
    * 保存${desc}
    * @param ${entityNameLower}
    * @return
    */
    public int insert(${entityName} ${entityNameLower}) {
        return ${entityNameLower}Mapper.insertSelective(${entityNameLower});
    }


<#if primaryKey!='noPrimaryKey'>
    /**
    * 根据ID更新${desc}
    * @param ${entityNameLower}
    * @return
    */
    public int update(${entityName} ${entityNameLower}) {
        return ${entityNameLower}Mapper.updateByPrimaryKeySelective(${entityNameLower});
    }

    /**
    * 删除${desc}
    * @param ${primaryKey}
    * @return
    */
    public int deleteByPrimaryKey(${javaKeyType} ${primaryKey}) {
        return ${entityNameLower}Mapper.deleteByPrimaryKey(${primaryKey});
    }

    /**
    * 根据查询${desc}
    * @param ${primaryKey}
    * @return
    */
    public ${entityName} get(${javaKeyType} ${primaryKey}) {
        return ${entityNameLower}Mapper.selectByPrimaryKey(${primaryKey});
    }
</#if>

    /**
    * 查询${desc}
    * @param ${entityNameLower}
    * @return
    */
    public List<${entityName}> findList(${entityName} ${entityNameLower}) {
        ${entityName}Criteria example=new ${entityName}Criteria();
        ${entityName}Criteria.Criteria criteria = example.createCriteria();
        //TODO add condition
        return ${entityNameLower}Mapper.selectByExample(example);
    }
}
